// SettingDlg.cpp : implementation file
//

#include "stdafx.h"
#include "lulutiper.h"
#include "SettingDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CSettingDlg dialog


CSettingDlg::CSettingDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CSettingDlg::IDD, pParent)
{
	CLuluTiperApp * pApp = (CLuluTiperApp *)AfxGetApp();
	//{{AFX_DATA_INIT(CSettingDlg)
	m_bAudio = pApp->cfg.bAudio;
	m_bCorner = pApp->cfg.bCorner;
	m_bSpalish = pApp->cfg.bSpalish;
	m_bDaily = pApp->cfg.bDaily;
	//}}AFX_DATA_INIT
}


void CSettingDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CSettingDlg)
	DDX_Check(pDX, IDC_CHECK_AUDIO, m_bAudio);
	DDX_Check(pDX, IDC_CHECK_CORNER, m_bCorner);
	DDX_Check(pDX, IDC_CHECK_SPALISH, m_bSpalish);
	DDX_Check(pDX, IDC_CHECK_DAILY, m_bDaily);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CSettingDlg, CDialog)
	//{{AFX_MSG_MAP(CSettingDlg)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSettingDlg message handlers

void CSettingDlg::OnOK() 
{
	// TODO: Add extra validation here
	UpdateData();

	CLuluTiperApp * pApp = (CLuluTiperApp *)AfxGetApp();
	pApp->cfg.bAudio = m_bAudio;
	pApp->cfg.bCorner = m_bCorner;
	pApp->cfg.bSpalish = m_bSpalish;
	pApp->cfg.bDaily = m_bDaily;

	CFile f;
	if (f.Open("config.cfg", CFile::modeCreate | CFile::modeReadWrite | CFile::typeBinary))
	{
		f.Write(&(pApp->cfg), sizeof(MYCONFIG));
	}

	CDialog::OnOK();
}
